﻿import QtQuick 2.12
import QtQuick.Layouts 1.12
import QtQuick.Window 2.12
import "./components/"
Window {
    title: "实验信息"
    modality: Qt.WindowModal
    flags: Qt.Window | Qt.WindowTitleHint |Qt.WindowSystemMenuHint | Qt.WindowCloseButtonHint

    height: 500*dp; width: 1000*dp

    function setValue(){
        sttime.setText(expDate)
        expConsumblesType.setIndex(expConsumblesTypeIndex)
        expConfigName.model=GetMessageInterface.getExperimentNameByConsumables(expConsumblesType.getText())
        expConfigName.setIndex(expSettingIndex)
    }

    Rectangle{
        width: parent.width
        height: parent.height

        Column{
            x: 20*dp; y: 10*dp
            height: parent.height - 30*dp
            width: parent.width - 40*dp
            spacing: (height-40*dp*6) / 5
            Rectangle{
                height: 40*dp; width: parent.width
                Text {
                    anchors.verticalCenter: parent.verticalCenter
                    text: qsTr("实验信息")
                    font.bold: true
                    font.pixelSize: config.fontsize + 3*dp
                }
            }
            Row{
                height: 40*dp
                width: parent.width
                spacing: 20*dp

                CustomComboBox {
                    id:expConsumblesType
                    editWidth: parent.width / 2 - 80*dp - 10*dp
                    title: "耗材名称"
                    model:GetMessageInterface.getConsumablesName()
                    onCurrentText: {
                        expConfigName.model=GetMessageInterface.getExperimentNameByConsumables(text)
                    }
                    CustomTooltip{
                        visible: parent.isHovered
                        text: "更换耗材后需要点击确认按钮"
                    }
                }

                CustomComboBox {
                    id:expConfigName
                    editWidth: parent.width / 2 - 80*dp - 10*dp-110*dp
                    title: "实验名称"
                    model: GetMessageInterface.getExperimentNameByConsumables(expConsumblesType.getText())
                    onCurrentText: {
                        var logData= GetMessageInterface.getExperimentLog(expConsumblesType.getText(),text)
                        experimentLog.setData(logData)
                        var otherData= GetMessageInterface.getOtherExperimentInfo();
                        expStep.text2=otherData["StepInfo"]
                        buzhouval.text=qsTr(otherData["StepInfo"])
                    }
                }

                CustomButton{
                    title: "确认"
                    width: 90*dp
                    defaultMode1: true
                    onReleased:
                    {
                        expConsumblesTypeName=expConsumblesType.getText()
                        expConsumblesTypeIndex=expConsumblesType.getIndex()
                        expSettingName=expConfigName.getText()
                        expSettingIndex=expConfigName.getIndex()
                        CommunicationMethod.setConsumable(expConsumblesType.getText())
                        CAnimation.reset()      // 动画复位
                    }
                }
            }

            Row{
                height: 40*dp
                width: parent.width
                spacing: 20*dp
                CustomInputText{
                    id:expName
                    editWidth: parent.width / 2 - 80*dp - 10*dp
                    title: "名       称"
                    inputMaxLength: 30
                    defaultText: name
                    onTextChanged: {
                        name=getText()
                    }
                }CustomInputText{
                    editable: false
                    editWidth: parent.width / 2 - 80*dp - 10*dp
                    title: "设备序号"
                    defaultText: "BK-RadPharm-001"
                }
            }
            Row{
                height: 40*dp
                spacing: 20*dp
                width: parent.width
                Text{
                    anchors.verticalCenter: parent.verticalCenter
                    text: "实验日期"
                    font.pixelSize: config.fontsize
                    width: 60*dp
                }
                CustomComboCalendar{
                    id: sttime
                    editWidth: parent.width / 2 - 80*dp - 10*dp
                    date: expDate
                    onDateChanged: {
                        expDate=date
                    }
                }
                CustomInputText{
                    editWidth: parent.width / 2 - 80*dp - 10*dp
                    title: "操  作  人"
                    defaultText: operator
                    inputMaxLength: 30
                    onTextChanged: {
                        operator=getText()
                    }
                }
                z:1
            }
            CustomInputText{
                editWidth: parent.width / 2 - 80*dp - 10*dp
                title: "耗材编码"
                defaultText: barCode
                onTextChanged: {
                    barCode=getText()
                }

                Image {
                    id: tm
                    source: "qrc:/picture/tm.png"
                    x:parent.width-85*dp
                    y:5*dp
                }
            }
            CustomInputText{
                editWidth: parent.width - 80*dp
                title: "描       述"
                defaultText: memo
                inputMaxLength: 50
                onTextChanged: {
                    memo=getText()
                }
            }
        }
    }
}
